package cn.iocoder.yudao.module.member.dal.mysql.signin;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.SignInExportReqVO;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.SignInPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.signin.SignInDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 用户签到 Mapper
 *
 * @author LinAllen
 */
@Mapper
public interface SignInMapper extends BaseMapperX<SignInDO> {

    default PageResult<SignInDO> selectPage(SignInPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SignInDO>()
                .eqIfPresent(SignInDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(SignInDO::getSignInTime, reqVO.getSignInTime())
                .eqIfPresent(SignInDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(SignInDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SignInDO::getId));
    }

    default List<SignInDO> selectList(SignInExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<SignInDO>()
                .eqIfPresent(SignInDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(SignInDO::getSignInTime, reqVO.getSignInTime())
                .eqIfPresent(SignInDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(SignInDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SignInDO::getId));
    }

}
